package com.hm.service.request.test;

import com.alibaba.fastjson2.JSON;
import com.hm.service.http.HttpUtils;
import com.hm.service.utils.CBC_Encryption;
import com.hm.service.utils.JsonUtils;
import com.hm.service.utils.Md5Utils;
import okhttp3.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.HexFormat;


/**
 * 获取session接口
 */
public class Request09 {

    private static final String url = "http://47.107.93.234:8081/export/record/000_000_000";


    public static void main(String[] args) {
        //请求参数
        String jsonObject = getJsonObject();
        //构建请求体
        RequestBody body = RequestBody.create(jsonObject, MediaType.get("application/json; charset=UTF-8"));
        Request request = new Request.Builder()//
                .url(url)//请求连接
                .post(body)//请求体
                .build();//构建
        //同步请求
        OkHttpClient okHttpClient = HttpUtils.getOkHttpClient();
        try (Response response = okHttpClient.newCall(request).execute()) {
            ResponseBody resBody = response.body();
            if (resBody != null) {
                String jsonString = resBody.string();
                System.out.println("1ResponseBody-->:" + jsonString);
            } else {
                System.out.println("ResponseBody为空");
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static String getJsonObject() {
        String startTime = "2025-07-01 11:00:00";
        String endTime = "2025-07-02 23:59:59";
        HashMap<String, String> paramsMap = new HashMap<>();
        paramsMap.put("startTime", startTime);
        paramsMap.put("endTime", endTime);
        return JSON.toJSONString(paramsMap);
    }
}